/**
 * Created by sun on 2015/3/12.
 */
package com.jbm;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;

public class GDEncoder extends ProtocolEncoderAdapter
{
	private final String charset;

	public GDEncoder(String charset)
	{
		this.charset = charset;
	}

	public void encode(IoSession session, Object message,
	                   ProtocolEncoderOutput out) throws Exception
	{
		IoBuffer buf = IoBuffer.allocate(100).setAutoExpand(true);
		byte[] bytes = (byte[])message;

		buf.put(bytes);
		buf.flip();

		out.write(buf);
	}
}
